<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\index\controller;

/**
 * Description of BaseController
 *
 * @author SoChishun
 */
class BaseController extends \think\Controller {

    protected $loginInfo = [];

    protected function _initialize() {
        parent::_initialize();
        $this->loginInfo = \think\Session::get('login');
        if (null == $this->loginInfo) {
            $this->error('登录超时或未登录', url('login/index'));
        }
        $user = \app\index\model\UserModel::get($this->loginInfo['id']);
        if (null == $user) {
            $this->error('用户已被删除', url('login/logout'));
        }
        if (!$user->status) {
            $this->error('用户已被禁用', url('login/logout'));
        }
        $this->loginInfo = $user->visible(['id', 'user_name', 'email', 'mobile', 'blance', 'currency'])->toArray();
        $this->assign('loginInfo', $this->loginInfo);
    }

}
